x86/shadow: drop (replace) bogus assertions
authorJan Beulich <jbeulich@suse.com>
Mon, 24 Oct 2022 13:46:11 +0000 (15:46 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 24 Oct 2022 13:46:11 +0000 (15:46 +0200)
commita92dc2bb30ba65ae25d2f417677eb7ef9a6a0fef
tree5f86602ee78eea111307ce31ca81e601f90f70e6
parentfce1f381f7388daaa3e96dbb0d67d7a3e4bb2d2d
x86/shadow: drop (replace) bogus assertions

The addition of a call to shadow_blow_tables() from shadow_teardown()
has resulted in the "no vcpus" related assertion becoming triggerable:
If domain_create() fails with at least one page successfully allocated
in the course of shadow_enable(), or if domain_create() succeeds and
the domain is then killed without ever invoking XEN_DOMCTL_max_vcpus.
Note that in-tree tests (test-resource and test-tsx) do exactly the
latter of these two.

The assertion's comment was bogus anyway: Shadow mode has been getting
enabled before allocation of vCPU-s for quite some time. Convert the
assertion to a conditional: As long as there are no vCPU-s, there's
nothing to blow away.

Fixes: e7aa55c0aab3 ("x86/p2m: free the paging memory pool preemptively")
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
A similar assertion/comment pair exists in _shadow_prealloc(); the
comment is similarly bogus, and the assertion could in principle trigger
e.g. when shadow_alloc_p2m_page() is called early enough. Replace those
at the same time by a similar early return, here indicating failure to
the caller (which will generally lead to the domain being crashed in
shadow_prealloc()).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-acked-by: Henry Wang <Henry.Wang@arm.com>
xen/arch/x86/mm/shadow/common.c